<template>
	<view>
		<view class="wrap">
			<view class="u-tabs-box">
				<u-tabs-swiper activeColor="#F8321D" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view>
			<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
				
				<!-- 全部订单内容 -->
				<swiper-item class="swiper-item">
					<scroll-view v-if="orderList[0].length"scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						
						<view class="page-box">
							<view class="order" v-for="(res, index) in orderList[0]" :key="res.id">
								<view class="top">
									<view class="left">
										<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
										<view class="store">{{ res.shopName }}</view>
										<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
									</view>
									<view class="right">{{ res.deal }}</view>
								</view>
								<view class="item" v-for="(item, index) in res.goodList" :key="index">
									<view class="left"><image :src="item.img" mode="aspectFill"></image></view>
									<view class="content">
										<view class="title u-line-2">{{ item.title }}</view>
										<view class="type">{{ item.sub_title}}</view>
									</view>
									<view class="right">
										<view class="price">
											￥{{ item.price |Int }}
											<text class="decimal">.{{ item.price |duts }}</text>
										</view>
										<view class="point">
											{{item.point}}分
										</view>
										<view class="number">x{{item.num}}</view>
									</view>
								</view>
								<view class="total">
									<text class="discont">
										总价
										<text class="dollor">￥</text>
										8999.
										<text class="dollor">00</text>
										 优惠 
										 <text class="dollor">￥</text>
										</text> 
									
									<text class="realcont">
										实付款:
										<text class="dollor">￥</text>6999.
										<text class="dollor">00</text>
									</text>
								</view>
								<view class="bottom">
									
									<view class="exchange btn">取消订单</view>
									<view class="exchange btn">付款</view>
									<view class="exchange btn">评价</view>
								</view>
							</view>
							<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
						</view>
					</scroll-view>
					<view v-else>
						<view class="centre">
							<image src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
							<view class="explain">
								您还没有相关的订单
								<view class="tips">可以去看看有那些想买的</view>
							</view>
							<view class="btn">随便逛逛</view>
						</view>
					</view>	
				</swiper-item>
				
				<!-- 待付款内容 -->
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						<view class="page-box">
							<view class="order" v-for="(res, index) in orderList[1]" :key="res.id">
								<view class="top">
									<view class="left">
										<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
										<view class="store">{{ res.shopName }}</view>
										<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
									</view>
								</view>
								<view class="item" v-for="(item, index) in res.goodList" :key="index">
									<view class="left"><image :src="item.img" mode="aspectFill"></image></view>
									<view class="content">
										<view class="title u-line-2">{{ item.title }}</view>
										<view class="type">{{ item.sub_title}}</view>
									</view>
									<view class="right">
										<view class="price">
											￥{{ item.price |Int }}
											<text class="decimal">.{{ item.price |duts }}</text>
										</view>
										<view class="point">
											{{item.point}}分
										</view>
										<view class="number">x{{item.num}}</view>
									</view>
								</view>
								<view class="total">
									<text class="discont">
										总价
										<text class="dollor">￥</text>
										8999.
										<text class="dollor">00</text>
										 优惠 
										 <text class="dollor">￥</text>
										</text> 
									
									<text class="realcont">
										实付款:
										<text class="dollor">￥</text>6999.
										<text class="dollor">00</text>
									</text>
								</view>
								<view class="bottom">
									
									<view class="exchange btn">取消订单</view>
									<view class="exchange btn">付款</view>
									
								</view>
							</view>
							<u-loadmore :status="loadStatus[1]" bgColor="#f2f2f2"></u-loadmore>
						</view>
					</scroll-view>
				</swiper-item>
				
				
				<!-- 代发货内容 -->
				<swiper-item class="swiper-item">
					<scroll-view v-if="orderList[2].length" scroll-y style="height: 100%;width: 100%;">
						<view class="page-box">
							<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
								<view class="page-box">
									<view class="order" v-for="(res, index) in orderList[2]" :key="res.id">
										<view class="top">
											<view class="left">
												<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
												<view class="store">{{ res.shopName }}</view>
												<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
											</view>
											<view class="right">{{ res.deal }}</view>
										</view>
										<view class="item" v-for="(item, index) in res.goodList" :key="index">
											<view class="left"><image :src="item.img" mode="aspectFill"></image></view>
											<view class="content">
												<view class="title u-line-2">{{ item.title }}</view>
												<view class="type">{{ item.sub_title}}</view>
											</view>
											<view class="right">
												<view class="price">
													￥{{ item.price |Int }}
													<text class="decimal">.{{ item.price |duts }}</text>
												</view>
												<view class="number">x{{item.num}}</view>
											</view>
										</view>
										<view class="total">
											<text class="discont">
												总价
												<text class="dollor">￥</text>
												8999.
												<text class="dollor">00</text>
												 优惠 
												 <text class="dollor">￥</text>
												</text> 
											
											<text class="realcont">
												实付款:
												<text class="dollor">￥</text>6999.
												<text class="dollor">00</text>
											</text>
										</view>
										<view class="bottom">
											<view class="exchange btn">取消订单</view>
										</view>
									</view>
									<u-loadmore :status="loadStatus[2]" bgColor="#f2f2f2"></u-loadmore>
								</view>
							</scroll-view>
						</view>
					</scroll-view>
					<view v-else>
						<view class="centre">
							<image src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
							<view class="explain">
								您还没有相关的订单
								<view class="tips">可以去看看有那些想买的</view>
							</view>
							<view class="btn">随便逛逛</view>
						</view>
					</view>
				</swiper-item>
				
				
				<!-- 待收货内容 -->
				<swiper-item class="swiper-item">
					<scroll-view v-if="orderList[3].length" scroll-y style="height: 100%;width: 100%;">
						<view class="page-box">
							<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
								<view class="page-box">
									<view class="order" v-for="(res, index) in orderList[3]" :key="res.id">
										<view class="top">
											<view class="left">
												<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
												<view class="store">{{ res.shopName }}</view>
												<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
											</view>
											<view class="right">{{ res.deal }}</view>
										</view>
										<view class="item" v-for="(item, index) in res.goodList" :key="index">
											<view class="left"><image :src="item.img" mode="aspectFill"></image></view>
											<view class="content">
												<view class="title u-line-2">{{ item.title }}</view>
												<view class="type">{{ item.sub_title}}</view>
											</view>
											<view class="right">
												<view class="price">
													￥{{ item.price |Int }}
													<text class="decimal">.{{ item.price |duts }}</text>
												</view>
												<view class="number">x{{item.num}}</view>
											</view>
										</view>
										<view class="total">
											<text class="discont">
												总价
												<text class="dollor">￥</text>
												8999.
												<text class="dollor">00</text>
												 优惠 
												 <text class="dollor">￥</text>
												</text> 
											
											<text class="realcont">
												实付款:
												<text class="dollor">￥</text>6999.
												<text class="dollor">00</text>
											</text>
										</view>
										<view class="bottom">
											<view class="exchange btn">评价</view>
											<view class="exchange btn">追加评价</view>
										</view>
									</view>
									<u-loadmore :status="loadStatus[3]" bgColor="#f2f2f2"></u-loadmore>
								</view>
							</scroll-view>
						</view>
					</scroll-view>
					<view v-else>
						<view class="centre">
							<image src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
							<view class="explain">
								您还没有相关的订单
								<view class="tips">可以去看看有那些想买的</view>
							</view>
							<view class="btn">随便逛逛</view>
						</view>
					</view>	
				</swiper-item>
				<!-- 待评价内容 -->
				<swiper-item class="swiper-item">
					<scroll-view v-if="orderList[4].length" scroll-y style="height: 100%;width: 100%;">
						<view class="page-box">
							<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
								<view class="page-box">
									<view class="order" v-for="(res, index) in orderList[4]" :key="res.id">
										<view class="top">
											<view class="left">
												<u-icon name="home" :size="30" color="rgb(94,94,94)"></u-icon>
												<view class="store">{{ res.shopName }}</view>
												<u-icon name="arrow-right" color="rgb(203,203,203)" :size="26"></u-icon>
											</view>
											<view class="right">{{ res.deal }}</view>
										</view>
										<view class="item" v-for="(item, index) in res.goodList" :key="index">
											<view class="left"><image :src="item.img" mode="aspectFill"></image></view>
											<view class="content">
												<view class="title u-line-2">{{ item.title }}</view>
												<view class="type">{{ item.sub_title}}</view>
											</view>
											<view class="right">
												<view class="price">
													￥{{ item.price |Int }}
													<text class="decimal">.{{ item.price |duts }}</text>
												</view>
												<view class="point">
													{{item.point}}分
												</view>
												<view class="number">x{{item.num}}</view>
											</view>
										</view>
										<view class="total">
											<text class="discont">
												总价
												<text class="dollor">￥</text>
												8999.
												<text class="dollor">00</text>
												 优惠 
												 <text class="dollor">￥</text>
												</text> 
											
											<text class="realcont">
												实付款:
												<text class="dollor">￥</text>6999.
												<text class="dollor">00</text>
											</text>
										</view>
										<view class="bottom">
											<view class="exchange btn">评价</view>
											<view class="exchange btn">追加评价</view>
										</view>
									</view>
									<u-loadmore :status="loadStatus[4]" bgColor="#f2f2f2"></u-loadmore>
								</view>
							</scroll-view>
						</view>
					</scroll-view>
					<view v-else>
						<view class="centre">
							<image src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
							<view class="explain">
								您还没有相关的订单
								<view class="tips">可以去看看有那些想买的</view>
							</view>
							<view class="btn">随便逛逛</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			orderList: [[
				{
					id:1,
					shopName: "富尔玛家居",
					photo:'@/static/icon/shop.png',
					deal:"交易成功",
					goodList: [{
							"id": "01",
							"title": "商品2",
							"img":"@/static/image/test.png",
							"sub_title": "KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price": 3444,
							"num": 3,
							"point":2000
						},
						{
							"id": "02",
							"title": "商品3",
							"sub_title": "KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price": 3444,
							"img":'@/static/image/test.png',
							"num": 0,
							"point":2000
						},
					]
				},
				{
					id:2,
					shopName:"穷尔驴家具",
					shopSelect:false,
					photo:'@/static/icon/shop.png',
					goodList:[
						{
							"id":"03",
							"title":"商品4",
							"sub_title":"KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price":3444,
							"img":"@/static/image/test.png",
							"num":0,
							"point":2000
						},
						{
							"id":"04",
							"title":"商品5",
							"sub_title":"KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price":3444,
							"img":"@/static/image/test.png",
							"num":0,
							"point":2000
						},
					]
				}
			], [
				{
					id:1,
					shopName: "富尔玛家居",
					photo:'@/static/icon/shop.png',
					goodList: [{
							"id": "01",
							"title": "商品2",
							"img":"@/static/image/test.png",
							"sub_title": "KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price": 3444,
							"num": 3,
							"point":2000
						},
					]
				},
			], [
				{
					id:1,
					shopName: "富尔玛家居",
					photo:'@/static/icon/shop.png',
					goodList: [{
							"id": "01",
							"title": "商品2",
							"img":"@/static/image/test.png",
							"sub_title": "KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price": 3444,
							"num": 3,
							"point":2000
						},
					]
				},
			], [],[
				{
					id:1,
					shopName: "富尔玛家居",
					photo:'@/static/icon/shop.png',
					goodList: [{
							"id": "01",
							"title": "商品2",
							"img":"@/static/image/test.png",
							"sub_title": "KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W KFR-26GW/NhPaB1W",
							"price": 3444,
							"num": 3,
							"point":2000
						},
					]
				},
			]],
			
			list: [
				{
					name:'全部'
				},
				{
					name: '待付款'
				},
				{
					name: '待发货'
				},
				{
					name: '待收货'
				},
				{
					name: '待评价'
				}
			],
			current: 0,
			swiperCurrent: 0,
			tabsHeight: 0,
			dx: 0,
			loadStatus: ['nomore','nomore','nomore','nomore'],
		};
	},
	computed: {
	},
	methods: {
		
		// 总价
		totalPrice(item) {
			let price = 0;
			item.map(val => {
				price += parseFloat(val.price) * val.num;
			});
			return price
		},
		// tab栏切换
		change(index) {
			this.swiperCurrent = index;
			this.getOrderList();
		},
		transition({ detail: { dx } }) {
			this.$refs.tabs.setDx(dx);
		},
		animationfinish({ detail: { current } }) {
			this.$refs.tabs.setFinishCurrent(current);
			this.swiperCurrent = current;
			this.current = current;
		}
	}
};
</script>

<style>
/* #ifndef H5 */
page {
	height: 100%;
	background-color: #f2f2f2;
}
/* #endif */
</style>

<style lang="scss" scoped>
.order {
	width: 710rpx;
	background-color: #ffffff;
	margin: 30rpx auto;
	border-radius: 20rpx;
	box-sizing: border-box;
	padding: 30rpx;
	font-size: 28rpx;
	.top {
		display: flex;
		justify-content: space-between;
		.left {
			display: flex;
			align-items: center;
			.store {
				margin: 0 10rpx;
				font-size: 30rpx;
				font-weight: bold;
			}
		}
		.right {
			color: #F8321D;
		}
	}
	.item {
		display: flex;
		margin: 40rpx 0 0;
		.left {
			margin-right: 20rpx;
			image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 10rpx;
			}
		}
		.content {
			.title {
				font-size: 22rpx;
				font-weight: 900;
				
			}
			.type {
				margin: 10rpx 0;
				font-size: 18rpx;
				color: #999999;
				line-height: 28rpx;

			}
			.delivery-time {
				color: #e5d001;
				font-size: 24rpx;
			}
		}
		.right {
			margin-left: 10rpx;
			
			text-align: right;
			.decimal {
				font-size: 24rpx;
				margin-top: 4rpx;
			}
			.point{
				color: #333333;
				font-size: 18rpx;
			}
			.number {
				color: $u-tips-color;
				font-size: 24rpx;
			}
		}
	}
	.total {
		margin-top: 20rpx;
		text-align: right;
		font-size: 28rpx;
		.total-price {
			font-size: 32rpx;
		}
		.discont{
			font-size: 28rpx;
			color: #999999;
		}
		.realcont{
			color: #333333;
		}
		.dollor{
			font-size:20rpx;
		}
	}
	.bottom {
		display: flex;
		margin-top: 40rpx;
		padding: 0 10rpx;
		justify-content: flex-end;
		align-items: center;
		.btn {
			line-height: 52rpx;
			width: 160rpx;
			border-radius: 26rpx;
			border: 2rpx solid $u-border-color;
			font-size: 26rpx;
			text-align: center;
			margin-left: 20rpx;
			color: $u-type-info-dark;
		}
		.evaluate {
			color: $u-type-warning-dark;
			border-color: $u-type-warning-dark;
		}
	}
}
.centre {
	text-align: center;
	margin: 200rpx auto;
	font-size: 32rpx;
	image {
		width: 164rpx;
		height: 164rpx;
		border-radius: 50%;
		margin-bottom: 20rpx;
	}
	.tips {
		font-size: 24rpx;
		color: #999999;
		margin-top: 20rpx;
	}
	.btn {
		margin: 80rpx auto;
		width: 200rpx;
		border-radius: 32rpx;
		line-height: 64rpx;
		color: #ffffff;
		font-size: 26rpx;
		background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
	}
}
.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}
.swiper-box {
	flex: 1;
}
.swiper-item {
	height: 100%;
}
</style>
